import java.util.*;

/**
 * 字符统计
 */
public class CountCharacter {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            Map<Character, Integer> map = new HashMap<>();
            for (int i=0; i<line.length(); i++) {
                if ((line.charAt(i) >= 'A' && line.charAt(i) <= 'Z') || (line.charAt(i) >= 'a' && line.charAt(i) <= 'z')
                    || (line.charAt(i) >= '0' && line.charAt(i) <= '9') || line.charAt(i) == ' '){
                    if (!map.containsKey(line.charAt(i))) {
                        map.put(line.charAt(i), 1);
                    } else {
                        map.put(line.charAt(i), map.get(line.charAt(i)) + 1);
                    }
                }
            }
            List<Map.Entry<Character, Integer>> list = new ArrayList<>(map.entrySet());
            list.sort(new Comparator<Map.Entry<Character, Integer>>() {
                @Override
                public int compare(Map.Entry<Character, Integer> o1, Map.Entry<Character, Integer> o2) {
                    if (o1.getValue().equals(o2.getValue())) {
                        int num = o1.getKey().compareTo(o2.getKey());
                        return num==0?1:num;
                    }
                    return o2.getValue().compareTo(o1.getValue());
                }
            });
            list.forEach(mapEntry -> System.out.print(mapEntry.getKey()));
            System.out.println();
        }
    }
}
